<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Common {
	public  $roleid;
	public  $c;
	public  $a;
	function __construct() 
	{
		$this->roleid= 0;
		$this->_CI = & get_instance();
		$this->c = $this->_CI->uri->segment('2');
		$this->a = $this->_CI->uri->segment('3');
	}
	 /**
	 * 获取顶部菜单函数
	 */
	public function submenu()
	{
		$data['top_menu'] = $this->_CI->cache->file->get('top_meun_'.$this->roleid);
		return $this->_CI->load->view('admin/top',$data,TRUE);
	}
    public function leftmenu()
	{
		$data['left_menu'] = $this->_CI->cache->file->get('left_meun_'.$this->roleid);
		return $this->_CI->load->view('admin/left',$data,TRUE);
	}
	public function short_menu()
	{
	    $data['short_menu'] = $this->_CI->cache->file->get('short_menu_'.$this->roleid);
   	  // print_r($data);exit;
		return $this->_CI->load->view('admin/short',$data,TRUE);
	}
	/**
	 * 系统操作提示函数  e.g:$this->common->adminmsg("修改失败！",0);
	 * @param string $msg_detail 提示文字
	 * @param int $msg_type 提示类型 0：结果错误  1：操作错误  2：结果成功
	 * @param array $links 链接
	 * @param bool $auto_redirect 是否自动跳转
	 * @param int $seconds 等待跳转的秒数
	 */
	public function adminmsg($msg_detail, $msg_type = 0, $links = array(), $auto_redirect = true,$seconds=3)
	{
		if (count($links) == 0)
		{
			$links[0]['text'] = lang('common_admin_backpage');
			$links[0]['href'] = 'javascript:history.go(-1)';
		}
		$data['ur_here'] = lang('common_admin_showmsg');
		$data['msg_detail'] = $msg_detail;
		$data['msg_type'] = $msg_type;
		$data['links'] = $links;
		$data['default_url'] = $links[0]['href'];
		$data['auto_redirect'] = $auto_redirect;
		$data['seconds'] = $seconds;
	
		$this->_CI->load->view('admin/admin_showmsg',$data);
	}
}